﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wicture.DbRESTFul;
using Wicture.EPC.OnlineQueryProxy.Processors;

namespace Wicture.EPC.OnlineQueryProxy.Proxy
{
    public class OnlineQueryResponseHandler : IOnlineQueryResponseHandler
    {
        public void ProcessQueryResult(QueryResponse response)
        {
            if (!response.HasError)
            {
                //QueryRecord.Cache(args.Code, args.Data);
                LoggerManager.Logger.LogInformation($"Received success query result for {response.Params} from Agent {response.AgentName}.");
            }
            else
            {
                LoggerManager.Logger.LogError($"Received failed query result: {response.Params} error: {response.ErrorMessage} from Agent {response.AgentName}.");
            }

            QueryContextManager.SetResult(response);
        }
    }
}
